//package com.lxw.station.chatgpt.spark;
//
//import ch.qos.logback.classic.Level;
//import ch.qos.logback.classic.Logger;
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.lxw.station.controller.GitProjectController;
//import org.slf4j.LoggerFactory;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.HttpMethod;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.client.RestTemplate;
//
//public class Hellospark {
//    public static String authorization = "Bearer 83cdfb704375d9377a755d2ae87a89d0:MjdlNTRmNTg3ZDljOTAyMzliODUzYjA4";
//    public static void main(String[] args) {
//        String content = GitProjectController.getContent("src/main/resources/tmp/README.md");
//        System.out.println(content);
//        System.out.println("============");
//        String s = titleandDesc(content);
//        System.out.println(s);
//
//    }
//
//    public static String titleandDesc(String content) {
//        String url = "https://spark-api-open.xf-yun.com/v1/chat/completions";
//        RestTemplate restTemplate = new RestTemplate();
//        Logger logger = (Logger) LoggerFactory.getLogger("ROOT");
//        logger.setLevel(Level.INFO);
//        HttpHeaders headers = new HttpHeaders();
//        headers.add("Authorization",authorization);
//        content = "你能对我提供的这段问题生成一个标题和一段描述吗?描述字数控制在500字以内,内容如下,\n"+content;
//        String param = "{\"model\": \"4.0Ultra\",\"messages\": [{\"role\": \"user\"}]}";
//        JSONObject jsonObject = JSON.parseObject(param);
//        jsonObject.getJSONArray("messages").getJSONObject(0).put("content",content);
//        HttpEntity<Object> entity = new HttpEntity<>(jsonObject,headers);
//        ResponseEntity<JSONObject> exchange = restTemplate.exchange(url, HttpMethod.POST, entity, JSONObject.class);
//        if (exchange.getStatusCode().equals(HttpStatus.OK)) {
//            JSONObject body = exchange.getBody();
//            return body.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getString("content");
//        }
//        return null;
//    }
//
//
//}
